
<?php include_once 'common/header.php';  ?>
<!-- admin_main -->
<div class="admin_main">
	<!-- Admin_top end -->
	<?php include_once 'common/system_left.php';  ?>
	<!-- Admin_Left End -->
	<div class="admin_right">
	<div class="admin_right_title"><strong>支付接口管理</strong> >> 第三方支付接口列表</div>

		<div class="admin_right_con" style="width: 98%">
			
			<table border="0" cellspacing="1" cellpadding="0" bgcolor="#cfe6f4" width="100%">
			  <tr style="color:#0068b7;">
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>ID</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>接口名称</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>标识</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>商户号</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>支付密钥</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>排序</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>是否启用</strong></td>
				<td height="35" align="center" valign="middle" bgcolor="#F1F1F1"><strong>操作</strong></td>
			  </tr>
			  <?php foreach($list as $key=>$info){
			  		$tmp = unserialize($info['config']);
			  	?>
			  <tr>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['id'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['name'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['nid'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $tmp['member_id'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $tmp['PrivateKey'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $info['payment_order'];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><?php echo $payment_fstatus[$info['fstatus']];?></td>
				<td height="35" align="center" valign="middle" bgcolor="#FFFFFF"><a  href="javascript:editpayment(<?php echo $info['id'];?>);" >修改 </a> </td>
			  </tr>
			  <?php }?>
			 
			</table>
			
			</div>
	</div>
<!-- Admin_Right End -->
</div>
<!-- admin_main end -->

<div id="dialog" title="系统提示" style="display:none;">
<div id="msg" style="text-align:center;color:red">&nbsp;</div>
<input type="hidden" name="id" id="id" />
<p id="paymentname"></p> <br />
<p id="paymentnid"></p> <br />
<p>商户号：<input type="text" name="member_id" id="member_id" /></p> <br />
<p>支付密钥：<input type="text" name="privateKey" id="privateKey" /></p> <br />
<p>排序：<input type="text" name="payment_order" id="payment_order" /></p> <br />
<p>描述：<input type="text" name="description" id="description" size="50" /></p> <br />
<p>是否启用：<input type="radio" name="fstatus" value="0" id="fstatus"/>是&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="fstatus" value="1" id="fstatus" />否&nbsp;&nbsp;&nbsp;&nbsp;</p> <br />						
<div style="text-align:center;">
<input type="button" style="width: 60px; height:24px" value="关闭" onclick="$('#dialog').dialog('close');"/>
<input type="button" style="width: 60px; height:24px" value="修改" onclick="submitpayment();" />
</div>
</div>

<script>

function editpayment(id){
	if(id>0){
		$( "#dialog" ).dialog({
			height:350,
			width:500,
			modal:true, //蒙层（弹出会影响页面大小）
			title:'编辑接口参数'
		});
		
		$( "#id").val(id);
		
		$.ajax({
			type: "POST",
			url: "/ychadmin/payment/pay_synchronize",
			data: "id="+$("#id").val(),
			success: function(ret){
				$("#paymentname").html('接口名称：'+ret.msg.name);
				$("#paymentnid").html('标识：'+ret.msg.nid);
				$("#member_id").val(ret.msg.member_id);
				$("#privateKey").val(ret.msg.privateKey);
				$("#payment_order").val(ret.msg.payment_order);
				$("#description").val(ret.msg.description);
				$("input[name=fstatus]:eq("+ret.msg.fstatus+")").attr("checked",'checked'); 
			},
			dataType: "json"
		});
	}
}

function submitpayment(){
	var id = $("#id").val();
	if(id > 0){
		$.ajax({
			type: "POST",
			url: "/ychadmin/payment/addparameter",
			data: "act=edit&id="+id+"&member_id="+$("#member_id").val()+"&privateKey="+$("#privateKey").val()+"&payment_order="+$("#payment_order").val()+"&description="+$("#description").val()+"&fstatus="+$('input:radio[name="fstatus"]:checked').val(),
			success: function(ret){
				$("#dialog" ).dialog();
				$("#msg").html(ret.msg);
				setTimeout(function(){
					$("#dialog" ).dialog("close");
				},5000);
				window.location.reload();
			},
			dataType: "json"
		});	
	}
}

function remove(id){
	if(confirm('你确定要删除?'))
	{
		if(id > 0){
			$.ajax({
				type: "POST",
				url: "/ychadmin/payment/addparameter",
				data: "act=delete&id="+id,
				success: function(ret){
					window.location.reload();
				},
				dataType: "json"
			});	
		}	
	}
}
</script>

</body>
</html>
